package eu.ahsx.limboa.media
{
	import flash.display.Loader;
	import flash.events.ErrorEvent;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.Font;
	
	/***
	 * 	FontLoader
	 * 	Load the font ressources
	 * 	
	 * 	@author Masy Alexandre
	 * 	@private
	 * */
	public class FontLoader extends AVM2Loader
	{
		public function FontLoader(debug:Boolean = false)
		{
			this.debug = debug;
			super(debug);
		}
		
		override public function load(file:MediaFile):void
		{
			if (!file.params.hasOwnProperty("fontname"))
				throw new Error("The fontname is required");
			
			super.load(file);
		}
		
		override protected function loadComplete(event:Event):void
		{
			super.loadComplete(event);
			
			var c:Class = file.info.domain.getDefinition("Helvetica") as Class;
			Font.registerFont(c);
			
			var a:Array = Font.enumerateFonts();
			var n:int = a.length;
			while(--n>=0)
				trace(Font(a[n]).fontName);
			
		}
	}
}